/*
 * @Description: 一杆一档接口
 * @Author: Huang Junjie
 * @Date: 2021-08-30 14:23:43
 * @LastEditTime: 2021-09-28 12:31:55
 * @LastEditors: Huang Junjie
 */
import request from '@/utils/request'

// 查询列表信息
export function getListPage(query) {
  var params = JSON.parse(JSON.stringify(query))
  delete params.unitCodeParams
  return request({
    url: query.unitCodeParams ? ('/jcwBasic' + query.unitCodeParams + '/jcwPillar/pageData') : '/jcwBasic/jcwPillar/pageData',
    method: 'GET',
    params: params
  })
}

// 根据id查询信息
export function getInfoById(query) {
  var params = JSON.parse(JSON.stringify(query))
  delete params.unitCodeParams
  return request({
    url: query.unitCodeParams ? ('/jcwBasic' + query.unitCodeParams + `/jcwPillar/getById`) : `/jcwBasic/jcwPillar/getById`,
    method: 'GET',
    params: params
  })
}

// 查询支柱下的设备分类
export function getPillarDeviceClass(query) {
  var params = JSON.parse(JSON.stringify(query))
  delete params.unitCodeParams
  return request({
    url: query.unitCodeParams ? ('/jcwBasic' + query.unitCodeParams + `/jcwPillar/deviceclass`) : `/jcwBasic/jcwPillar/deviceclass`,
    method: 'GET',
    params: params
  })
}

// 查询固有参数信息列表
export function getAddtionParam(query) {
  var params = JSON.parse(JSON.stringify(query))
  delete params.unitCodeParams
  return request({
    url: query.unitCodeParams ? ('/jcwBasic' + query.unitCodeParams + `/jcwPillar/properties`) : `/jcwBasic/jcwPillar/properties`,
    method: 'GET',
    params: params
  })
}

// 新增/修改信息
export function addOrEditData(query) {
  var params = JSON.parse(JSON.stringify(query))
  delete params.unitCodeParams
  return request({
    url: query.unitCodeParams ? ('/jcwBasic' + query.unitCodeParams + '/jcwPillar/saveOrUpdateData') : '/jcwBasic/jcwPillar/saveOrUpdateData',
    method: 'POST',
    data: params
  })
}

// 删除信息
export function deleteData(query) {
  var params = JSON.parse(JSON.stringify(query))
  delete params.unitCodeParams
  return request({
    url: query.unitCodeParams ? ('/jcwBasic' + query.unitCodeParams + `/jcwPillar/${params.id}`) : `/jcwBasic/jcwPillar/${params.id}`,
    method: 'DELETE'
  })
}

// 查询字典数据信息列表
export function getDict(query) {
  var params = JSON.parse(JSON.stringify(query))
  delete params.unitCodeParams
  return request({
    url: query.unitCodeParams ? ('/jcwBasic' + query.unitCodeParams + '/jcwPillar/getDict/') : '/jcwBasic/jcwPillar/getDict/',
    method: 'get',
    data: params
  })
}

// 根据id查询附件
export function getFileList(query) {
  var params = JSON.parse(JSON.stringify(query))
  delete params.unitCodeParams
  return request({
    url: query.unitCodeParams ? ('/jcwBasic' + query.unitCodeParams + '/jcwPillar/getFile') : '/jcwBasic/jcwPillar/getFile',
    method: 'GET',
    params: params
  })
}

// 保存附件
export function editFileList(query) {
  var params = JSON.parse(JSON.stringify(query))
  delete params.unitCodeParams
  return request({
    url: query.unitCodeParams ? ('/jcwBasic' + query.unitCodeParams + '/jcwPillar/uploadFile') : '/jcwBasic/jcwPillar/uploadFile',
    method: 'POST',
    data: params
  })
}
